<!-- 领导选人 -->
 <template>
  <el-dialog :visible.sync="visible" v-dialogDrag :title="title" :close-on-click-modal="false" class="tl-dialog" width="1200px" @open="open" @close="close">
    <el-form class="tl-form" ref="form" :model="model" :rules="rules" label-width="150px" :disabled="disableEditSubmit">
      <el-row>
        <el-col :span="24">
          <el-form-item label="需求说明" prop="requirementdescription" :rules="rules.rulesForCompetitorInfo">
            <el-input v-model="model.requirementdescription" type="textarea" :rows="4" maxlength="1000" show-word-limit></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="传阅人" prop="circulatedcode" :rules="rules.rulesForInfo">
            <tl-ref-user v-model="model.circulatedcode" :initDisplayData.sync="model.circulatedname" dataType="code" :singleSelect="false">
            </tl-ref-user>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button :type="disableEditSubmit === false ? 'text' : 'primary'" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doSubmitEdit" :loading="saveLoading" v-if="disableEditSubmit === false">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
/** mixins */
import { mixin_edit } from '@tapui/mixins/mixin_edit'

/** 子组件 */
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
import refListVue from '../pmIndexTabPermission/refList.vue'
/** VUE配置 */
export default {
  mixins: [mixin_edit],
  components: {},
  data() {
    return {
      moduleTitle: '项目传阅反馈',
      urlPrefix: '/mpm/projectCirculated/',
      url: {
        list: 'list'
      },
      tempParam: [], // 临时参数
      isAdd: true, // 是否添加
      addRules: {
        // 基本信息TAB表单校验
        rulesForInfo: [
          { required: 'true', message: '请输入内容', trigger: 'change' }
        ],
        rulesForCompetitorInfo: [
          { required: 'true', message: '请输入内容', trigger: 'change' }
        ]
      }
    }
  },
  methods: {
    loaded() {
      var projectCode = this.$parent.model.projectcode
      return getAction(this.urlPrefix + this.url.list, { projectCode: projectCode, latestphase: "01" })
        .then((res) => {
          if (res.success) {
            if (res.result.dataList !== null && res.result.dataList.length > 0) {
              this.isAdd = false
              this.model = res.result.dataList[0]
            }
          } else {
            this.$tap.alert(res.message, 'warning')
          }
        })
    },
    // 拼装请求参数
    getEditParams() {
      this.$set(this.model, 'username', this.model.username)
      this.$set(this.model, 'usercode', this.model.usercode)
      this.$set(this.model, 'circulatedname', this.model.circulatedname)
      this.$set(this.model, 'circulatedcode', this.model.circulatedcode)
      this.$set(this.model, 'projectmanager', this.user.name)
      this.$set(this.model, 'projectmanagercode', this.user.code)
      this.$set(this.model, 'latestphase', '02') // 直属领导选人阶段
      this.$set(this.model, 'state', '0') // 未经项目经理确认的人，属于临时状态
    },
    doSubmitEdit() {
      this.getEditParams()
      this.$refs.form.validate((valid) => {
        this.doAdd()
      })
    }
  }
}
</script>

